var content = $("#content");
$(document).ready(function(){
    loadPage();
    loadLoginInfo();

    $(window).unload(function(){
       alert("再见！");
    });
});

function loadPage() {
	$.ajax({
		url : '/blog/getAllBlog',
		contentType : 'application/json',
		type : 'get',
		cache : false,
		dataType : 'json',
		success:function(data) {
			var htmlContent = '';

			if(data.code == 200 ){
				var result = data.dataList;
				$(result).each(
					function (index, item) {
						htmlContent += '<div class="item">';
						htmlContent += '<a href="page/blog-detail.html?id='+ item.id + '" target="_blank"><P class="item_title">';
						htmlContent += item.title;
						htmlContent += '</P></a>';
						htmlContent += '<P class="item_label">这里写标签' + index + '</P>';
						htmlContent += '</div>';
					}
				);
			}else{

			}
			content.html(htmlContent);
		 },
		 error : function() {
		    console.log("error")
		 }
	});
}

function loadLoginInfo() {
    var nickname = JSON.parse(window.localStorage.getItem("userInfo")).nickname;
    $("#header>p").text(nickname)
}

